package com.zcxy.fast.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zcxy.fast.anotation.Dict;
import com.zcxy.fast.entity.SysMenu;
import com.zcxy.fast.handler.DictSerializer;
import com.zcxy.fast.mybatisExtend.anotation.JoinColumn;
import com.zcxy.fast.mybatisExtend.anotation.OneToMany;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 平台-菜单表Vo对象
 *
 * @author zcc
 * @email 860474958@qq.com
 * @date 2021-02-02 08:48:57
 */
@Data
@ApiModel(value = "SysMenuVo", description = "平台-菜单表Vo")
public class SysMenuVo {


    @Dict("menu_type")
    @JsonSerialize(using = DictSerializer.class)
    @ApiModelProperty(value = " 菜单类型", required = false)
    private String menuType;


    @ApiModelProperty(value = " 菜单名称", required = false)
    private String name;


    @ApiModelProperty(value = " 菜单路径", required = false)
    private String url;


    @ApiModelProperty(value = " 前端组件", required = false)
    private String component;


    @ApiModelProperty(value = " 默认跳转", required = false)
    private String redirect;


    @ApiModelProperty(value = " 图标", required = false)
    private String icon;


    @ApiModelProperty(value = " 菜单路由", required = false)
    private String vueRouter;


    @ApiModelProperty(value = " 排序", required = false)
    private Integer orderNo;


    @ApiModelProperty(value = " 父菜单id", required = false)
    private String parentId;


    @ApiModelProperty(value = " 备注", required = false)
    private String remark;


    @ApiModelProperty(value = " 权限标识字符串", required = false)
    private String perms;


    @ApiModelProperty(value = " 权限状态", required = false)
    private String permsStatus;


    @ApiModelProperty(value = " 是否叶子节点(0否1是)", required = false)
    private String leafFlag;


    @ApiModelProperty(value = " 系统属性(1平台2租户)", required = false)
    private String sysType;


    @ApiModelProperty(value = " 状态(0停用1正常)", required = false)
    private String status;


    @ApiModelProperty(value = " 主键", required = false)
    private String id;


    private boolean hasChildren;

    @OneToMany(targetEntity = SysMenu.class)
    @JoinColumn(name = "id", referencedColumnName = "parent_id")
    private List<SysMenu> sysMenus;

    public boolean isHasChildren() {
        if (CollectionUtil.isNotEmpty(sysMenus)) {
            return true;
        }
        return false;
    }


}
